package com.cn.system.service;

import com.cn.system.entity.BaseResponse;

import java.util.List;

public interface BaseService<T> {

  /**
   *  gain data from unique databases;
   * @return if database exist with select condition match, return from unique data
   * else return null;
   */
  public T get(String id);

  /**
   * gain condition from database;
   * @param t entity
   * @return
   */
  public List<T> list(T t);

  /**
   * 带分页天剑查询
   * @param startIndex 开始下标
   * @param endIndex 结束下标
   * @param t
   * @return
   */
  public BaseResponse<T> page(int startIndex, int endIndex, T t);


  /**
   * According to entity object from databases update data.
   * @param t entity
   * @return
   */
  public int update(T t);

  /**
   * According to unique flag from databases delete data.
   * @param id unique flag
   */
  public int delete(String id);

  /**
   * add data to databases.
   * @param t entity object
   * @return
   */
  public int add(T t);
}
